package main

import (
	"AR/saas/arApi/internal/config"
	"AR/saas/arApi/internal/handler"
	"AR/saas/arApi/internal/svc"
	"flag"
	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/rest"
)

type ArApi struct {
	server *rest.Server
}

func (a *ArApi) Start() {
	flag.Parse()
	configFile := flag.String("f", "etc/ar-api.yaml", "the config file")

	var c config.Config
	conf.MustLoad(*configFile, &c)

	a.server = rest.MustNewServer(c.RestConf)

	ctx := svc.NewServiceContext(c)
	handler.RegisterHandlers(a.server, ctx)
	a.server.Start()
}

func (a *ArApi) Stop() {
	a.server.Stop()
}
